package DesignMode.Singleton;

/**
 * 懒汉线程安全, 在第一种上添加 synchronized 字段，效率不高，因为同步块会进入排队
 */
public class Singleton2 {
    public static Singleton2 singleton2;
    private Singleton2() {}

    public static synchronized Singleton2 getSingleton2() {
        if(singleton2 == null) {
            return new Singleton2();
        }
        return singleton2;
    }
}
